<template>
<div style="width: 100%">
   <a-alert banner message="温馨提示：慎重操作,此操作将批量生成听课名单(只要培养计划内有该课程编号的学生,都将进入听课名单中)" style="margin:20px 0"/>
  <a-card >
    <a-form :form="form" layout="vertical">
      <a-row :gutter="48">
        <a-col :md="6" :sm="12">
          <a-form-item
            label="年级"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-select v-decorator="['sznj',
              {
                rules: [{ required: true, message: '请选择年级!' }],
              }]">
              <a-select-option v-for="i in TYPE0126" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
       
        <a-col :md="6" :sm="12">
          <a-form-item
            label="学年"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-select v-decorator="['ksxn',
              {
                rules: [{ required: true, message: '请选择学年!' }],
              }]">
              <a-select-option v-for="i in TYPE0125" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
         <a-col :md="6" :sm="12">
          <a-form-item
            label="学期"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-select v-decorator="['xqm',
              {
                rules: [{ required: true, message: '请选择学期!' }],
              }]">
              <a-select-option v-for="i in TYPE0072" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <a-col :md="6" :sm="12">
          <a-form-item
            label="课程编号"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-input
              v-decorator="['kcdm']"
            />
          </a-form-item>
        </a-col>
      </a-row>
      <a-row :span="24" style="text-align: center">
        <a-button type="primary" @click="handleSave">保存</a-button>
      </a-row>
    </a-form>
  </a-card>
  </div>
</template>
<script>
// import moment from 'moment'
import { mapState } from 'vuex'
// const qsString = (data) => { // 将对象转成url串格式
//     let stringObj = ''
//     if (typeof (data) === 'undefined' || data === null || typeof (data) !== 'object') {
//         return ''
//     }
//     for (let k in data) {
//       stringObj += ((stringObj.indexOf('=') !== -1) ? '&' : '') + k + '=' + encodeURI(data[k])
//     }
//     return stringObj
//   }


export default {
  name: 'pkEditTime',
  data () {
    return {
    }
  },
  computed: {
    ...mapState({
      TYPE0125: state => state.app['TYPE0125'],
      TYPE0126: state => state.app['TYPE0126'],
      TYPE0072: state => state.app['TYPE0072']
    })
  },
  beforeCreate () {
    this.form = this.$form.createForm(this)
    this.$store.dispatch('app/setDictionary', 'TYPE0125')
    this.$store.dispatch('app/setDictionary', 'TYPE0126')
    this.$store.dispatch('app/setDictionary', 'TYPE0072')
  },
  created () {
  },
  methods: {
    // 保存操作
    handleSave () {
      this.form.validateFields((err, values) => {
        if (err) {
          return
        }
        this.$api.cultivate.createTkxsmd(values).then(res => {
          this.$message.success(res.msg)
        })
      })
    }
  }
}
</script>
